﻿
using System.ConfigCenter.Server.Models;

using GCC.Container.Abstracts;

using Grpc.Core;

namespace System.ConfigCenter.Server
{
    [GCCGRPCServer]
    public class SystemConfigurationsServices : SystemConfigurations.SystemConfigurationsBase
    {
        public SystemConfigurationsServices()
        {
        }

        public override Task<GetByPathResponse> GetByPath(GetByPathRequest request, ServerCallContext context)
        {
            return Task.Run(() =>
            {
                var path = new List<string>();
                foreach (var item in request.Path)
                {
                    path.Add(item);
                }
                return new GetByPathResponse()
                {
                    Value = SystemConfigInfo.GetByPath(path.ToArray())
                };
            });
        }
    }
}
